home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1838 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: gryphon.phoenix.net!usenet
  2. From: brucew@phoenix.net (Bruce Wedding)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: What is wrong ?
  5. Date: Wed, 17 Jan 1996 07:00:33 GMT
  6. Organization: BranPaul Systems
  7. Message-ID: <4di4gr$674@gryphon.phoenix.net>
  8. References: <4df373$kd3@ns.etri.re.kr>
  9. NNTP-Posting-Host: dial73.phoenix.net
  10. X-Newsreader: Moe's Newsreader    
  11.  
  12. jinsoo@etri.re.kr (Jin-Soo Lee) wrote:
  13.  
  14. >#define DSKPAGESIZE     16*1024
  15. >#define LOGBUFSIZE      2*DSKPAGESIZE
  16.  
  17. You need to wrap these in parentheses.  They are expanding and then
  18. the order of evaluation is getting hosed.
  19.  
  20. (1)     pageBS = (logoffset/LOGBUFSIZE) * LOGBUFSIZE;
  21.  
  22. expands to (logoffset / 2 * 16 * 1024) * 2 * 16 * 1024
  23.  
  24. logoffset is divided by 2 then multiplied by 16 then 1024
  25.  
  26. >(2)     bufferoffset = (logoffset + length)%LOGBUFSIZE;
  27. this becomes (logoffset+length) % 2 * 16 * 1024
  28. The modulus is done with the 2, not (2*16*1024)
  29.  
  30. etc etc.
  31.  
  32.  
  33. Bruce D. Wedding                        Have Compiler, Will Travel!
  34.               Perspicacious Programming Performed Promptly
  35. Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
  36.  
  37.